package com.example.server.controller;


import com.example.server.pojo.Admin;
import com.example.server.service.IAdminService;
import com.example.server.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CuiQingFeng
 * @since 2022-09-01
 */
@RestController
public class AdminController {

    @Autowired
    private IAdminService adminService;

    @PostMapping("/login")
    public RespBean login(@RequestBody Admin admin, HttpServletRequest request) {

        /**
         * 1. 收集客户端传递多来的数据
         * 1.1 数据校验
         * 2. 将这些数据传递给service，执行业务逻辑
         * 3. service执行完成，获取到执行结果
         * 4. 将结果封装，发送给客户端
         */

        RespBean respBean = adminService.login(admin, request.getSession());

        return respBean;
    }
}
